import { un } from '@uni-helper/uni-network'

export const httpInstance = un.create({
  baseUrl: 'https://exam.tykhrs.site',
  timeout: 5000,
})

httpInstance.interceptors.request.use(
  (config) => {
    return config
  },
  (error) => {
    uni.showToast({ title: '请求失败', icon: 'none' })
    return Promise.reject(error)
  },
)

httpInstance.interceptors.response.use(
  (response) => {
    return response
  },
  (error) => {
    uni.showToast({ title: '服务器错误', icon: 'none' })
    return Promise.reject(error)
  },
)
